package com.chapter.sample.answer.controller;

import com.chapter.sample.entity.member.MemberEntity;
import com.chapter.sample.service.datasource.DynamicDatasourceService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class RedisCacheController {
    @Resource
    private DynamicDatasourceService dynamicDatasourceService;

    @RequestMapping("/member/add")
    public boolean addMember(@RequestBody MemberEntity member) {
        return dynamicDatasourceService.addMember(member);
    }

    @RequestMapping("/member/{id}")
    public MemberEntity getMemberById(@PathVariable("id") Integer id) {
        return dynamicDatasourceService.getMemberById(id);
    }
}
